package com.dataex.dbtool;

import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 字符串操作工具类
 * 
 * @author haoxw
 * @since 2014/4/10
 */
public class ImpStringUtil extends org.apache.commons.lang.StringUtils {

	private static final Logger log = LoggerFactory.getLogger(ImpStringUtil.class);

	public static byte[] toBytes(String s) {
		try {
			return s != null ? s.getBytes("UTF-8") : null;
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}

	public static String toStr(byte[] b) {
		try {
			return b != null ? new String(b, "UTF-8") : null;
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}

	/**
	 * 获取字符串的长度，中文占一个字符,英文数字占半个字符
	 * 
	 * @param value
	 *            指定的字符串
	 * @return 字符串的长度
	 */
	public static double strLength(String value) {
		double valueLength = 0;
		String chinese = "[\u4e00-\u9fa5]";
		// 获取字段值的长度，如果含中文字符，则每个中文字符长度为2，否则为1
		for (int i = 0; i < value.length(); i++) {
			// 获取一个字符
			String temp = value.substring(i, i + 1);
			// 判断是否为中文字符
			if (temp.matches(chinese)) {
				// 中文字符长度为1
				valueLength += 1;
			} else {
				// 其他字符长度为0.5
				valueLength += 0.5;
			}
		}
		// 进位取整
		return Math.ceil(valueLength);
	}

	/**
	 * 字符串连接
	 * 
	 * @param strs
	 * @return
	 */
	public static String contactString(String... strs) {
		StringBuilder sb = new StringBuilder();
		for (String str : strs) {
			sb.append(str);
		}
		return sb.toString();
	}

	/**
	 * 字符串连接
	 * 
	 * @param strs
	 * @return
	 */
	public static String concatenateString2(String sep, Object... strs) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < strs.length; i++) {
			if (strs[i] == null) {
				continue;
			}
			sb.append(strs[i]);
			if (i != strs.length - 1) {
				sb.append(sep);
			}
		}
		return sb.toString();
	}

	public static String asciiReverse(String data) {
		if (data == null)
			return null;

		int len = data.length();

		if (len == 0)
			return data;

		StringBuilder str_buf = new StringBuilder(len);
		for (int i = 0; i < len; i++) {
			char in = data.charAt(i);

			if (in >= 0 && in < 128) {
				in = (char) (127 - in);
			}
			str_buf.append(in);
		}

		return str_buf.toString();
	}

	/**
	 * 按指定长度裁减字符串用于显示（英文字符1,中文字符2） note:
	 * 函数对中文做了特殊处理，因此如果输入中含有中文，应该调用此函数，否则，直接通过String的length操作判断
	 * 
	 * @param str
	 * @param splitLen
	 * @return
	 */
	public static String splitDisplayString(String str, int splitLen) {
		if (str == null)
			return null;

		char[] result = new char[splitLen];
		int dislpayLen = 0;
		int j = 0;
		int len = str.length();
		for (int i = 0; i < len; ++i) {
			char ch = str.charAt(i);
			if (ch > '\u00FF')
				dislpayLen = dislpayLen + 2;
			else
				dislpayLen++;
			if (dislpayLen <= splitLen)
				result[j++] = ch;
			else
				break;
		}
		return new String(result, 0, j);
	}

	/**
	 * 第一个参数，传入的是要截的中英文字符串，第二个参数，要截取的长度。 /**
	 * 截取字符串(汉字按两个字符算),如果截取的长度刚好是汉字的中间,那舍弃这个汉字
	 * 这个规则和subStringWithChinese方法的规则不一样,所以没有重复
	 * 
	 * @param str
	 * @param subBytes
	 * @return str
	 */
	public static String subStringWithChinese(String str, int subBytes) {
		if (ImpStringUtil.isNotEmpty(str)) {
			// int byteLen = str.length();
			int bytes = 0; // 用来存储字符串的总字节数
			for (int i = 0; i < str.length(); i++) {
				if (bytes == subBytes) {
					return str.substring(0, i);
				}
				char c = str.charAt(i);
				if (c < 256) {
					bytes += 1; // 英文字符的字节数看作1
				} else {
					bytes += 2; // 中文字符的字节数看作2
					if (bytes - subBytes == 1) {
						return str.substring(0, i);
					}
				}
			}
		}
		return str;
	}

	/**
	 * 汉字当1位
	 * 
	 * @param str
	 * @param beginIndex
	 * @param endIndex
	 * @return
	 */
	public static String subStringWithChinese(String str, int beginIndex, int endIndex) {
		if (endIndex <= beginIndex)
			return null;

		int bytesLen = str.length();
		String subStr = null;
		int bytes = 0; // 用来存储字符串的总字节数
		for (int i = 0; i < str.length(); i++) {
			if (bytes == beginIndex) {
				subStr = str.substring(i, bytesLen);
				bytes = i;
				break;
			}
			char c = str.charAt(i);
			if (c < 256) {
				bytes += 1; // 英文字符的字节数看作1
			} else {
				bytes += 2; // 中文字符的字节数看作2
				if (bytes - beginIndex == 1) {
					subStr = str.substring(i, bytesLen);
					bytes = i;
					break;
				}
			}
		}

		String retStr = subStringWithChinese(subStr, endIndex - bytes);
		return retStr;
	}

	/**
	 * 计算字符串字节数（英文字符1,中文字符2） note:
	 * 函数对中文做了特殊处理，因此如果输入中含有中文，应该调用此函数，否则，直接通过String的length操作判断
	 * 
	 * @see #getStrLength(String)
	 * @deprecated
	 */
	public static int displayLength(String str) {
		return getStrLength(str);
	}

	/**
	 * 验证一个可能含有中文的字符串长度是否在指定的长度范围内 note:
	 * 函数对中文做了特殊处理，因此如果输入中含有中文，应该调用此函数，否则，直接通过String的length操作判断
	 * 
	 * @param str
	 * @param maxLength
	 * @return 如果大于最大值，则返回false，否则返回true
	 */
	public static boolean validateMaxLength(String str, int maxLength) {
		int length = str.length();

		// 只有字符串在最大长度和最大长度的1/2之间才去获取实际长度
		if (length <= maxLength && length > maxLength / 2) {
			return !(ImpStringUtil.displayLength(str) > maxLength);
		}
		return (length <= maxLength);
	}

	/**
	 * 功能：获取字符串长度，一个汉字等于两个字符
	 * 
	 * @param str
	 *            字符串
	 * @return 字符串长度
	 */
	public static int getStrLength(String str) {
		if (str == null || str.length() == 0)
			return 0;
		int count = 0;
		for (char c : str.toCharArray()) {
			count += c < 256 ? 1 : 2;
		}
		return count;
		// int bytes = 0; // 用来存储字符串的总字节数
		// for (int i = 0; i < str.length(); i++) {
		// char c = str.charAt(i);
		// if (c < 256) {
		// bytes += 1; // 英文字符的字节数看作1
		// } else {
		// bytes += 2; // 中文字符的字节数看作2
		// }
		// }
		//
		// return bytes;
	}

	/**
	 * 验证一个可能含有中文的字符串长度是否在指定的长度范围内 note:
	 * 函数对中文做了特殊处理，因此如果输入中含有中文，应该调用此函数，否则，直接通过String的length操作判断
	 * 
	 * @param str
	 * @param minLength
	 * @return 如果小于最小值，则返回false，否则返回true
	 */
	public static boolean validateMinLength(String str, int minLength) {
		int length = str.length();

		if (length >= minLength)
			return true;
		// 只有字符串在最大长度和最大长度的1/2之间才去获取实际长度
		if (length < minLength && length >= minLength / 2) {
			return !(ImpStringUtil.displayLength(str) < minLength);
		}
		return (length > minLength);
	}

	/**
	 * 截取字符串(汉字按两个字符算),如果截取的长度刚好是汉字的中间,那舍弃这个汉字
	 * 这个规则和subStringWithChinese方法的规则不一样,所以没有重复
	 * 
	 * @param s
	 *            要截取的字符串,必须是gbk的编码
	 * @param length
	 *            要截取的长度
	 * @return 截取后的字符串
	 */
	public static String subString(String s, int length) {
		try {
			byte[] bytes = s.getBytes("gbk");
			if (length >= bytes.length) {
				return s;
			}
			// 如果截取的字符串的汉字字节个数是奇数个,就舍弃最后一个
			byte[] afterBytes = new byte[length];
			System.arraycopy(bytes, 0, afterBytes, 0, length);
			int count = 0;
			for (byte b : afterBytes) {
				if (b < 0) {
					count++;
				}
			}
			String returnStr = new String(afterBytes, 0, afterBytes.length, "gbk");
			if (count % 2 != 0) {
				returnStr = new String(afterBytes, 0, afterBytes.length - 1, "gbk");
			}
			return returnStr;
		} catch (Exception e) {
			log.error("字符截取失败", e);
			return s;
		}
	}

	public static String subStringWithSuffix(String s, int length, String suffix) {
		try {
			if (ImpStringUtil.isEmpty(s)) {
				return "";
			}
			byte[] bytes = s.getBytes("gbk");
			if (length >= bytes.length) {
				return s;
			}
			return subString(s, length) + suffix;
		} catch (Exception e) {
			log.error("字符截取失败", e);
			return s;
		}
	}

	public static String subStringBefore(int start, String s, String pos) {
		int index = s.indexOf(pos);
		if (index < 0)
			return s;
		return s.substring(start, index);
	}

	/*
	 * 截取转译之后的字符串，避免截取到转译出乱码，截取了无效链接，截取了@
	 */
	public static String subStringEscapeMessycode(String str, int length) {
		try {
			if (getStrLength(str) > length) {
				String content = subStringWithChinese(str, length);
				if (content.matches(".*http://[0-9a-zA-Z#\\./\\?&=-]*$")) {// 处理无效链接
					content = content.substring(0, content.lastIndexOf("http://"));
				} else if (content.matches(".*&[0-9a-zA-Z#]{0,6}$")) {// 处理转译乱码
					content = content.substring(0, content.lastIndexOf("&"));
				} else if (content.matches(".*@[\\u4e00-\\u9fa5\\w-]+$")) {// 处理无效@
					content = content.substring(0, content.lastIndexOf("@"));
				}
				return content;
			} else {
				return str;
			}
		} catch (Exception e) {
			log.info("subStringEscapeMessycode failed,the string is:" + str + ";length is" + length);
			return str;
		}
	}

	/**
	 * 去掉前后空格
	 * 
	 * @param content
	 * @return
	 */
	public static String trim(String content) {
		if (null != content) {
			return content.trim();
		}
		return content;
	}

	/**
	 * 去掉前后空格
	 * 
	 * @param content
	 * @return
	 */
	public static String trimRight(String src, String del) {
		if (ImpStringUtil.isEmpty(del))
			return src;
		if (ImpStringUtil.isEmpty(src))
			return src;
		if (src.length() < del.length())
			return src;
		if (src.substring(src.length() - del.length(), src.length()).equals(del)) {
			return src.substring(0, src.length() - del.length());
		}
		return src;
	}

	private static final boolean isChinese(char c) {
		Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
		if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
				|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
				|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
			return true;
		}
		return false;
	}

	/**
	 * 按字节长度截取字符串
	 * 
	 * @param src
	 * @param length
	 *            将要截取的字符串参数
	 * @param more
	 *            字符串末尾补上的字符串
	 * @param withEmoji
	 *            {[, ]} 截取
	 * @param maxByteCount
	 *            按 byte 取值, >0 时起作用
	 * @return
	 */
	public static String subString_ByEmoji(String src, int length, String more, boolean withEmoji, int maxByteCount) {
		if (ImpStringUtil.isEmpty(src)) {
			return "";
		}

		String beginMatch = "{[";
		String endMatch = "}]";
		int machIndex = 0;

		double strLength = strLength(src);
		if (strLength <= length && maxByteCount <= 0) {
			return src;
		} else {

			int emojiLen = 0;
			int dislpayLen = 0;
			int byteCount = 0;
			int lastI = 0; // 最后的表情位置, 截取是[微信][微笑], 不能截取[微信][微 这样的字符

			int i = 0;
			for (; i < src.length(); ++i) {

				if ((dislpayLen > length) && emojiLen == 0)
					break;

				// 超过255个byte, 中断, ios 推送会失败
				char ch = src.charAt(i);
				if (isChinese(ch))
					byteCount += 3;
				else
					byteCount++;
				if (maxByteCount > 0 && byteCount > maxByteCount) {
					String data = src.substring(0, i);
					if (lastI > 0)
						i = lastI;
					@SuppressWarnings("unused")
					int len = data.getBytes().length;
					break;
				}

				// check emoji char
				if (emojiLen > 7) {
					dislpayLen += emojiLen;
					emojiLen = 0;
					lastI = 0;
				}

				// 开始检查enomji
				if (emojiLen > 0) {

					// 找到 右匹配字符
					if (ch < 256 && machIndex != -1 && (endMatch.indexOf(ch) == machIndex)) {
						dislpayLen++;
						emojiLen = 0;
						lastI = 0;
						continue;
					}

					// [[aa] 这样的情况, 找到 左匹配字符
					if (ch < 256 && withEmoji && (beginMatch.indexOf(ch) >= 0)) {
						emojiLen = 1;
						lastI = i;
						machIndex = beginMatch.indexOf(ch);
						dislpayLen++;
						continue;
					}
					emojiLen++;
					continue;
				}

				// 找到 左匹配字符
				if (ch < 256 && withEmoji && ((machIndex = beginMatch.indexOf(ch)) >= 0)) {
					emojiLen = 1;
					lastI = i;
					continue;
				}
				// end emojichar
				dislpayLen++;
			}

			// 截取字符串
			String data = src.substring(0, i);
			if (i < src.length())
				data += more;
			return data;
		}
	}

	/**
	 * 将分割字符串转为 Set<Long> 结构,
	 * 
	 * @param str
	 * @return 始终有返回值
	 */
	public static Set<Long> commaStringToSet(String str, String sep) {
		List<Long> listVal = ImpStringUtil.commaStringToList(str, sep);
		return ImpCollUtil.ListToSet(listVal);
	}

	/**
	 * 将分割字符串转为 Set<String> 结构,
	 * 
	 * @param str
	 * @return 始终有返回值
	 */
	public static Set<String> commaStringToSetStr(String str, String sep) {
		String[] arr = str.split(sep);
		Set<String> hash = new java.util.HashSet<String>();
		for (String v : arr)
			hash.add(v);
		return hash;
	}

	/**
	 * 将分割字符串转为 List<Long> 结构,
	 * 
	 * @param str
	 * @return 始终有返回值
	 */
	public static List<Long> commaStringToList(String str, String sep) {
		String[] arr = str.split(sep);
		List<Long> set = new ArrayList<Long>();
		for (String s : arr) {
			try {
				set.add(Long.parseLong(s));
			} catch (NumberFormatException e) {
				log.info("" + e);
				continue;
			}
		}
		return set;
	}

	public static String commaStringFromColl(Collection<?> coll, String sep) {
		StringBuilder bld = new StringBuilder();

		int cur = 0;
		for (Object ss : coll) {
			bld.append(ss.toString());
			if (cur + 1 != coll.size())
				bld.append(sep);
			cur++;
		}
		return bld.toString();
	}

	/**
	 * 
	 * @param set
	 * @param sep
	 * @return
	 */
	public static String SetToCommaString(Set<Long> set, String sep) {
		StringBuilder bld = new StringBuilder();
		for (Long ss : set) {
			bld.append(String.valueOf(ss));
			bld.append(sep);
		}
		return bld.toString();
	}

	public static String getStringFromCollection(Collection<?> colls, String sep) {
		StringBuilder sb = new StringBuilder();

		for (Iterator<?> it = colls.iterator(); it.hasNext();) {
			Object o = it.next();
			sb.append(o);
			sb.append(sep);
		}
		return sb.toString();
	}

	public static String toString(Object obj) {
		if (obj == null)
			return "null";
		else
			return obj.toString();
	}

	public static long parseLong(String s) {
		long i = 0L;
		try {
			i = Long.parseLong(s);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return i;
	}

	public static int parseInt(String s) {
		int i = 0;
		try {
			i = Integer.parseInt(s);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return i;
	}

	public static boolean checkEmail(String email) {
		boolean flag = false;
		try {
			String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
			Pattern regex = Pattern.compile(check);
			Matcher matcher = regex.matcher(email);
			flag = matcher.matches();
		} catch (Exception e) {
			flag = false;
		}
		return flag;
	}

	/**
	 * 验证手机号码
	 * 
	 * @param mobiles
	 * @return
	 */
	public static boolean checkMobileNumber(String mobileNumber) {
		boolean flag = false;
		try {
			Pattern regex = Pattern.compile("^(((13[0-9])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8})|(0\\d{2}-\\d{8})|(0\\d{3}-\\d{7})$");
			Matcher matcher = regex.matcher(mobileNumber);
			flag = matcher.matches();
		} catch (Exception e) {
			flag = false;
		}
		return flag;
	}

	/**
	 * 截取字符串source中begin到end之间的字符串
	 * 
	 * @param source
	 *            源字符串
	 * @param begin
	 *            开始
	 * @param end
	 *            结束
	 * @param startIndex
	 *            开始位置
	 * @return
	 */
	public static String getStringBtw(String source, String begin, String end, int startIndex) {
		String result = "";
		if (!source.contains(begin)) {
			return result;
		} else if (!source.contains(end)) {
			return result;
		}
		int beginIndex = source.indexOf(begin, startIndex);
		int endIndex = source.indexOf(end, beginIndex + begin.length());
		if (endIndex == -1)
			return result;

		result = source.substring(beginIndex + begin.length(), endIndex);
		return result;
	}

	public static int saveToFile(String fileName, String val) {

		FileWriter fwriter = null;
		try {
			fwriter = new FileWriter(fileName);
			fwriter.write(val);
		} catch (IOException ex) {
			ex.printStackTrace();
		} finally {
			try {
				if (fwriter != null) {
					fwriter.flush();
					fwriter.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
		return 1;
	}

	/**
	 * 判断两个字符串是否相等 str1==null && str2 == null , return true str1==null str2 !=
	 * null, return fasle; str1 != null str2 == null, return false; return
	 * str1.equals(str2)
	 * 
	 * @param str1
	 * @param str2
	 * @return 相等 true, 否则 false
	 */
	public static boolean Equal(String str1, String str2) {
		if (str1 == null && str2 == null)
			return true;
		if (str1 == null || str2 == null)
			return false;
		return str1.equals(str2);
	}

	/**
	 * 
	 * @param val
	 * @param wantLen
	 * @param ch
	 * @return
	 */
	public static String FillupWith(String val, int wantLen, char ch) {
		int dis = wantLen - val.length();
		if (dis <= 0)
			return val;

		StringBuffer fix = new StringBuffer();
		for (int i = 0; i < dis; i++)
			fix.append(ch);
		return val + fix.toString();
	}

	public static String getStringByKeyHash(String tablePrefix, String key, int tableNum) {
		int numcode = key.hashCode();
		if (numcode == Integer.MIN_VALUE) {
			numcode = Integer.MAX_VALUE;
		}
		int num = Math.abs(numcode);
		num = num % tableNum;
		return tablePrefix + num;
	}

	public static String getSqlUpdateStr(String tableName, Map<String, Object> column, Set<String> keyCol) {
		// "insert into table app_org_active_num,app_type,analyse_type,app_active_num,app_active_rate,analyse_time) values(?,?,?,?,?,?)";
		// "update code_record set join_count=?, update_time=? where id=?";
		StringBuilder str = new StringBuilder();
		str.append("update ").append(tableName).append(" set ");
		for (Map.Entry<String, Object> en : column.entrySet()) {
			if (en.getValue() == null)
				continue;
			str.append(en.getKey()).append("=?,");
		}
		str.setCharAt(str.length() - 1, ' ');

		StringBuilder str2 = new StringBuilder();
		for (String strK : keyCol) {
			if (str2.length() > 0)
				str2.append(" and ");
			str2.append(strK).append("=?");
		}

		str.append(" where ").append(str2);
		return str.toString();
	}

	public static String getSqlInsertStr(String tableName, Map<String, Object> column) {
		// "insert into table app_org_active_num,app_type,analyse_type,app_active_num,app_active_rate,analyse_time) values(?,?,?,?,?,?)";
		StringBuilder str = new StringBuilder();
		StringBuilder str2 = new StringBuilder();
		str.append("insert into ").append(tableName + " ");
		str.append("(");
		for (Map.Entry<String, Object> en : column.entrySet()) {
			str.append(en.getKey() + ",");
			str2.append("?,");
		}
		str.setCharAt(str.length() - 1, ' ');
		str2.setCharAt(str2.length() - 1, ' ');
		str.append(") values (");
		str.append(str2);
		str.append(")");
		return str.toString();
	}

	public static void doTest() {

		String ss = String.format("%06d", 200);
		System.out.println(ss);

		ss = String.format("%06d", 21);
		System.out.println(ss);

	}

	public static String numBitToChineseBit(String str, int start, int end) {

		if (end == -1)
			end = str.length() - 1;
		if (start < 0)
			start = 0;
		StringBuilder sb = new StringBuilder(str);
		for (int i = start; i <= end; i++) {
			switch (sb.charAt(i)) {
			case '0':
				sb.setCharAt(i, '〇');
				break;
			case '1':
				sb.setCharAt(i, '一');
				break;
			case '2':
				sb.setCharAt(i, '二');
				break;
			case '3':
				sb.setCharAt(i, '三');
				break;
			case '4':
				sb.setCharAt(i, '四');
				break;
			case '5':
				sb.setCharAt(i, '五');
				break;
			case '6':
				sb.setCharAt(i, '六');
				break;
			case '7':
				sb.setCharAt(i, '七');
				break;
			case '8':
				sb.setCharAt(i, '八');
				break;
			case '9':
				sb.setCharAt(i, '九');
				break;
			default:
				break;
			}
		}
		return sb.toString();
	}

	public static String numToChineseNum(String dateD, int start, int end) {
		if (start < 0)
			start = 0;
		if (end < 0)
			end = dateD.length() - 1;
		StringBuilder sb = new StringBuilder(dateD);
		StringBuilder subNum = new StringBuilder();
		for (int i = end; i >= start; i--) {
			if (Character.isDigit(sb.charAt(i))) {
				subNum.insert(0,sb.charAt(i));
			} 
			else {
				if (subNum.length() > 0) {
					sb.delete(i+1, i +1 + subNum.length());
					String num = NumberText.getInstChs().getText(subNum.toString());
					sb.insert(i+1, num);
					subNum.setLength(0);
				}
			}
			
			if ( i== start && subNum.length() > 0){
				sb.delete(i, i + subNum.length());
				String num = NumberText.getInstChs().getText(subNum.toString());
				sb.insert(i, num);
				subNum.setLength(0);
			}
		}

		return sb.toString();
	}

	// public static void main(String a[]) {
	//
	// doTest();
	//
	// System.out.println(ImpStringUtil.strLength("qweqwe第三方123qwe"));
	// @SuppressWarnings("unused")
	// boolean b = ImpStringUtil.Equal(null, "ffs");
	//
	// String s = "{23}{333}{22}我发我发我发我aaaff";
	//
	// String s2 =
	// "[微笑][撇嘴][色][发呆][得意][流泪][害羞][呲牙][调皮][尴算的法司暗色调法是尬][大哭][睡觉][闭嘴][惊讶][难过][酷][冷汗][抓狂][吐][偷笑][惊恐][困][饥饿][傲慢][白眼][笑脸][流汗][憨笑][悠闲][奋斗][咒骂][疑问][嘘][擦汗][再见][敲打][骷髅]";
	//
	// String data = ImpStringUtil.subString_ByEmoji(s, 4, ".....", true, 0);
	//
	// String stt = "\"波浪\"";
	// int len = 256 - (stt+"22").getBytes(Charset.forName("UTF-8")).length;
	// data = ImpStringUtil.subString_ByEmoji(s2, 40, ".....", true, len);
	//
	// String aa =
	// "侯少静:方立柱同意了石屏马瑞马瑞督导提交的请示单：上次抬柜台扭到腰，使不出力气，店里男的少，所以申请请2人搬柜台，共80元，柜台不好拉线，买插板2个，接电的同时还可以给摆柜机充电，2个插板40元，搬运人员和插板";
	// data = ImpStringUtil.subString_ByEmoji(aa, 100, "", true, 200);
	// len = data.getBytes(Charset.forName("UTF-8")).length;
	// aa += "34";
	// aa += stt;
	// len = aa.getBytes(Charset.forName("UTF-8")).length;
	//
	//
	// System.out.println(len);
	// }
}
